<?php

namespace App\Http\Controllers\Counter;

use App\Enums\FastRemarkType;
use App\Helper\ApiResponseHelper;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\FastRemark;
use App\Http\Requests\Counter\FastRemarkRequest;
use App\Http\Resources\Counter\FastRemarkResource;

class FastRemarkController extends Controller
{
    public function getList(Request $request)
    {
        $type = $request->type ?? FastRemarkType::Default;

        $fastRemarks = FastRemark::where('type', $type)->get();
        return FastRemarkResource::collection($fastRemarks);
    }

    public function create(FastRemarkRequest $request)
    {
        $fastRemark = FastRemark::create($request->only([
            'remark', 'type'
        ]));

        return new FastRemarkResource($fastRemark);
    }

    public function remove(FastRemark $fastRemark)
    {
        $fastRemark->delete();

        return ApiResponseHelper::json([]);
    }
}
